/*
 * *******************************************************************
 *   @项目名称: BHex Android
 *   @文件名称: OtcPayChannelApi.java
 *   @Date: 19-1-14 上午10:51
 *   @Author: ppzhao
 *   @Description:
 *   @Copyright（C）: 2019 BlueHelix Inc.   All rights reserved.
 *   注意：本内容仅限于内部传阅，禁止外泄以及用于其他的商业目的.
 *  *******************************************************************
 */

package io.bhex.sdk.otc;

import io.bhex.baselib.network.BParamsBuilder;
import io.bhex.baselib.network.HttpUtils;
import io.bhex.baselib.network.listener.SimpleResponseListener;
import io.bhex.baselib.network.params.PostParams;
import io.bhex.baselib.network.response.ResultResponse;
import io.bhex.baselib.utils.MD5Utils;
import io.bhex.sdk.OTCUrls;
import io.bhex.sdk.otc.bean.OtcPayChannelListResponse;
import io.bhex.sdk.otc.bean.OtcPaymentChannelBean;

public class OtcPayChannelApi {
    /**
     * 获取可用支付渠道列表
     */
    public static void getPayChannelList(SimpleResponseListener<OtcPayChannelListResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_PAYMENT_LIST)
                .build();
        HttpUtils.getInstance().request(params, OtcPayChannelListResponse.class, listener);

    }

    /**
     * 设置/更新 收款渠道
     *  @param isUpdateReceipt
     * @param updateReceiptBean
     * @param realName
     * @param payType
     * @param bankName
     * @param branchName
     * @param accountNo
     * @param qrcode
     * @param tradePwd
     * @param listener
     */
    public static void setReceiptChannel(boolean isUpdateReceipt, OtcPaymentChannelBean updateReceiptBean, String realName, int payType, String bankName, String branchName, String accountNo, String qrcode, String tradePwd, SimpleResponseListener<ResultResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(isUpdateReceipt ? OTCUrls.OTC_PAYMENT_UPDATE : OTCUrls.OTC_PAYMENT_CREATE)
                .addParam("id",isUpdateReceipt&&updateReceiptBean!=null?updateReceiptBean.getId():0l)
                .addParam("paymentType",payType)
                .addParam("realName",realName)
                .addParam("bankName",bankName)
                .addParam("branchName",branchName)
                .addParam("accountNo",accountNo)
                .addParam("qrcode",qrcode)
                .addParam("tradePwd",MD5Utils.encode(tradePwd))
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class, listener);
    }

    /**
     * 删除支付渠道
     */
    public static void deletePayWay(long paymentId,String tradePwd,SimpleResponseListener<ResultResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_PAYMENT_DETELE)
                .addParam("id",paymentId)
                .addParam("tradePwd",MD5Utils.encode(tradePwd))
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class, listener);
    }

    /**
     * 删除支付渠道
     * onOff 开关 0开 1关
     */
    public static void switchPayWay(long paymentId,int onOff,SimpleResponseListener<ResultResponse> listener) {
        PostParams params = BParamsBuilder.post()
                .url(OTCUrls.OTC_PAYMENT_SWITCH)
                .addParam("id",paymentId)
                .addParam("visible",onOff)
                .build();
        HttpUtils.getInstance().request(params, ResultResponse.class, listener);
    }

}
